package com.jzz.eletuanbackend.util;


import com.alibaba.fastjson.JSONObject;

public class Msg {
    private int code;
    private String message;
    private Object data;

    public Msg() {

    }

    public Msg(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Msg ok(String message, Object data) {
        return new Msg(0, message, data);
    }

    public static Msg ok(Object data) {
        return new Msg(0, "success", data);
    }

    public static Msg err(int code, String message) {
        return new Msg(code, message, null);
    }

    public static Object count(int count, String message, Object data) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 0);
        jsonObject.put("message", message);
        jsonObject.put("count", count);
        jsonObject.put("data", data);
        return jsonObject;
    }

    public static Object count(int count, Object data) {
        return count(count, "success", data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
